import type { TreeNodeData } from '@arco-design/web-vue'
import http from '@/utils/http'
import type {ConfigValueState, LabelValueState} from '@/types/global'
import type { OptionQuery } from '@/apis'

const BASE_URL = '/business'

/** @desc 查询部门树 */
export function listDeptTree(query: { description: string | undefined }) {
  return http.get<TreeNodeData[]>(`${BASE_URL}/dept/getArcoDeptList`, query)
}

/** @desc 查詢題型樹 */
export function subjectTree() {
  return http.get<TreeNodeData[]>(`${BASE_URL}/subject/getUnitTopicTypes`)
}

/** @desc 查詢題型樹 */
export function subjectDeleteTree() {
  return http.get<TreeNodeData[]>(`${BASE_URL}/subject/getUnitDeleteTopicTypes`)
}




/** @desc 查詢地址樹 */
export function addressTree() {
  return http.get<TreeNodeData[]>(`${BASE_URL}/provinceCityArea/getAddressTrees`)
}


/** @desc 查詢企業樹 */
export function getEnterpriseTrees() {
  return http.get<TreeNodeData[]>(`${BASE_URL}/customer/getEnterpriseTrees`)
}



/** @desc 查詢分類樹 */
export function getCategoryTrees() {
  return http.get<TreeNodeData[]>(`${BASE_URL}/broadcastCategory/getTrees`)
}


/** @desc 查询菜单树 */
export function listMenuTree(query: { description: string }) {
  return http.get<TreeNodeData[]>(`${BASE_URL}/sysMenu/getRoleMenus`, query)
}

/** @desc 查询角色列表 */
export function listRoleDict(query?: { name: string, status: number }) {
  return http.get<LabelValueState[]>(`${BASE_URL}/role/getRoles`, query)
}

/** @desc 查询字典列表 */
export function listCommonDict(code: string) {
  return http.get<LabelValueState[]>(`${BASE_URL}/dict/${code}`)
}

/** @desc 查询参数列表 */
export function listOptionDict(query: OptionQuery) {
  return http.get<ConfigValueState[]>(`${BASE_URL}/websiteConfig/list`, query)
}

/** @desc 上传文件 */
export function uploadFile(data: FormData) {
  return http.post(`${BASE_URL}/file/oss_upload`, data)
}
